package com.link2room.soundwave.thirdController.ipms2;

import com.link2room.common.exception.SysException;
import com.link2room.soundwave.dto.result.base.PMSNotifyDto;
import com.link2room.soundwave.facade.IPMSNotifyFacadeService;
import greencloud.ipms2.param.IPMSNotifyParamDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by VegetaKo on 2017/3/17.
 */
@RestController
@RequestMapping("/third/IPMS2Notify")
public class IPMS2Notify {
    private static Logger logger = LoggerFactory.getLogger(IPMS2Notify.class);
    @Resource(name = "PMSNotifyFacadeService")
    private IPMSNotifyFacadeService PMSNotifyFacadeService;



    @RequestMapping(value="/SendWXMesage",method = RequestMethod.POST)
    public PMSNotifyDto listGoodCategorys(
            @RequestParam(value = "templateId" ,required = false) String templateId,
            @RequestParam (value = "openId" ,required = false) String openId,
            @RequestParam (value = "data" ,required = false) String data
    ) throws Exception {

        IPMSNotifyParamDto paramDto = new IPMSNotifyParamDto();
        paramDto.setTemplateId(templateId);
        paramDto.setOpenid(openId);
        paramDto.setData(data);
        PMSNotifyDto res = new PMSNotifyDto();
        try {
            res = PMSNotifyFacadeService.notifyPmsGSS(paramDto);
        }catch (SysException e) {
            logger.error(e.getMessage());
            res.setErrcode(String.valueOf(e.getCode()));
            res.setErrmsg(String.valueOf(e.getMessage()));
        } finally {
            return res;
        }
    }
}
